import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:top_foundation/component/tag.dart';
import 'package:top_foundation/top_foundation.dart';
import 'package:whale/helper/global/global.dart';
import 'package:whale/helper/route/routes.dart';
import 'package:whale/helper/utils/color.dart';
import 'package:whale/helper/utils/img_util.dart';
import 'package:whale/pages/app_tab/index.dart';
import 'package:whale/pages/home/main/logic.dart';
import 'package:whale/pages/means/model/means_model.dart';

import '../../../../helper/utils/MyUnderlineTabIndicator.dart';

class QuickReview extends GetView<HomeLogic> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          key: controller.state.keyGreen1,
          padding: EdgeInsets.all(15.r),
          height: 55.r,
          child: Row(
            children: [
              Text(
                '系统速审',
                style: TextStyle(
                    color: ColorsUtil.title,
                    fontSize: 16.r,
                    fontWeight: FontWeight.bold),
              ),
              Spacer(),
              InkWell(
                onTap: () {
                  GlobalState().meansTabIndex.value = 0;
                  final ctrl = Get.find<AppTabController>();
                  ctrl.clickTab(1);
                },
                child: Text(
                  '查看更多',
                  style: TextStyle(color: ColorsUtil.subTitle, fontSize: 12.r),
                ),
              ),
              SizedBox(
                width: 5.r,
              ),
              Image.asset(
                'icon_right.png'.imgPathMe,
                width: 4.5.r,
                height: 8.r,
              )
            ],
          ),
        ),
        Container(
          margin: EdgeInsets.symmetric(horizontal: 15.r),
          color: Colors.white,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              TabBar(
                controller: controller.state.review_tabCtrl,
                isScrollable: true,
                indicatorColor: ColorsUtil.title,
                unselectedLabelColor: ColorsUtil.subTitle,
                labelColor: ColorsUtil.title,
                labelStyle:
                    TextStyle(fontSize: 14.r, fontWeight: FontWeight.w600),
                unselectedLabelStyle: TextStyle(fontSize: 14.r),
                indicator: MyUnderlineTabIndicator(
                    borderSide:
                        const BorderSide(width: 3, color: ColorsUtil.title)),
                onTap: (int index) =>
                    controller.getPageDoc(type: index == 0 ? '政策措施' : '招标采购'),
                tabs: controller.state.tabTitles
                    .map((e) => Tab(text: e))
                    .toList(),
              ),
              Container(
                height: 0.5.r,
                color: Color(0xffF4F4F5),
                margin: EdgeInsets.symmetric(vertical: 4.r),
              ),
              ListView.separated(
                itemBuilder: (context, index) {
                  var md = controller.state.docZB[index];
                  var riskColors = md.riskColors;
                  return Container(
                      child: InkWell(
                    onTap: () {
                      Get.toNamed(RouterPath.means_detail,
                          arguments: controller.state.docZB[index]);
                    },
                    child: Container(
                      color: Colors.white,
                      padding: EdgeInsets.symmetric(
                          horizontal: 15.r, vertical: 11.r),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            controller.state.docZB[index].documentTitle ?? '',
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                color: ColorsUtil.title,
                                fontSize: 14.r,
                                fontWeight: FontWeight.w500),
                          ),
                          SizedBox(
                            height: 10.r,
                          ),
                          Row(
                            children: [
                              Container(
                                // padding: EdgeInsets.symmetric(horizontal: 8.r),
                                height: 24.r,
                                width: 48.r,
                                alignment: Alignment.center,
                                decoration: BoxDecoration(
                                    color: riskColors.last,
                                    borderRadius: BorderRadius.circular(2)),
                                child: Text(
                                  md.riskLevel ?? '',
                                  style: TextStyle(
                                    color: riskColors.first,
                                    fontSize: 11.sp,
                                  ),
                                ),
                              ),
                              SizedBox(
                                width: 10.r,
                              ),
                              Text(
                                controller.state.docZB[index].createTime ?? '',
                                style: TextStyle(
                                    color: ColorsUtil.content, fontSize: 10.sp),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  ));
                },
                padding: EdgeInsets.zero,
                itemCount: controller.state.docZB.length,
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                separatorBuilder: (BuildContext context, int index) =>
                    Container(
                  height: 0.5.r,
                  color: Color(0xffF4F4F5),
                  margin: EdgeInsets.symmetric(horizontal: 15.r),
                ),
              ),
            ],
          ),
        ),
        SizedBox(
          height: 15.r,
        ),
        Stack(
          children: [
            Container(
              width: 0.9.sw,
              margin: EdgeInsets.only(left: 0.1.sw, right: 15.r),
              padding: EdgeInsets.only(right: 12.r),
              decoration: BoxDecoration(
                  color: Color(0xFFE1EAFB),
                  borderRadius: BorderRadius.circular(2.r)),
              child: Align(
                alignment: Alignment.centerRight,
                child: Image.asset(
                  'bg_tag.png'.imgPathHome,
                  width: 69.r,
                  height: 53.r,
                ),
              ),
              height: 110.r,
            ),
            Container(
              width: 0.65.sw,
              margin: EdgeInsets.only(left: 12.r, top: 10.r),
              decoration: BoxDecoration(
                  gradient: const LinearGradient(
                    colors: [Color(0xFFD3AE82), Color(0xFFB49A7A)],
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                  ),
                  borderRadius: BorderRadius.circular(4.r),
                  boxShadow: const [
                    BoxShadow(
                        color: Colors.grey,
                        offset: Offset(0, 1), //阴影y轴偏移量
                        blurRadius: 5, //阴影模糊程度
                        spreadRadius: 1 //阴影扩散程度
                        ),
                  ]),
              height: 90.r,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      SizedBox(
                        width: 20.r,
                      ),
                      Container(
                        margin: EdgeInsets.only(top: 5.r, right: 10.r),
                        child: Text(
                          '新增疑似违规文件',
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 13.r,
                              fontWeight: FontWeight.w600),
                        ),
                      ),
                      Text(
                        controller.state.docSum?.reviewedDocumentSum
                                ?.newDocumentSum
                                .toString() ??
                            '',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 24.r,
                            fontWeight: FontWeight.w600),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8.r,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      SizedBox(
                        width: 20.r,
                      ),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            '系统对接',
                            style:
                                TextStyle(color: Colors.white, fontSize: 10.r),
                          ),
                          SizedBox(
                            height: 5.r,
                          ),
                          Text(
                            controller.state.docSum?.reviewedDocumentSum
                                    ?.sysDocumentSum
                                    .toString() ??
                                '',
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 11.r,
                                fontWeight: FontWeight.w600),
                          ),
                        ],
                      ),
                      Container(
                        width: 1.r,
                        color: Color(0xFFB29877),
                        height: 16.r,
                        margin: EdgeInsets.symmetric(horizontal: 15.r),
                      ),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            '云上采集',
                            style:
                                TextStyle(color: Colors.white, fontSize: 10.r),
                          ),
                          SizedBox(
                            height: 5.r,
                          ),
                          Text(
                            controller.state.docSum?.reviewedDocumentSum
                                    ?.cloudDocumentSum
                                    .toString() ??
                                '',
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 11.r,
                                fontWeight: FontWeight.w600),
                          ),
                        ],
                      ),
                      Container(
                        width: 1.r,
                        color: Color(0xFFB29877),
                        height: 16.r,
                        margin: EdgeInsets.symmetric(horizontal: 15.r),
                      ),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            '自主上传',
                            style:
                                TextStyle(color: Colors.white, fontSize: 10.r),
                          ),
                          SizedBox(
                            height: 5.r,
                          ),
                          Text(
                            controller.state.docSum?.reviewedDocumentSum
                                    ?.ownUploadDocumentSum
                                    .toString() ??
                                '',
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 11.r,
                                fontWeight: FontWeight.w600),
                          ),
                        ],
                      ),
                    ],
                  )
                ],
              ),
            ),
          ],
        )
      ],
    );
  }
}
